/**
 * 
 */
package com.pmsco.pms.services.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pmsco.pms.core.dao.MedicineDao;
import com.pmsco.pms.core.domain.Medicine;
import com.pmsco.pms.services.interfaces.MedicineService;

/**
 * @author Long Tran
 *
 */
public class MedicineServiceImpl implements MedicineService {
	private static final Logger logger = LoggerFactory.getLogger(MedicineServiceImpl.class);

	private static MedicineDao medicineDao;
	
	public Medicine getMedicineByName(String name) {
		logger.info("Start getMedicineByName");
		logger.debug("Name: " + name);
		Medicine medicine = new Medicine();
		medicine.setName(name);
		logger.info("End getMedicineByName");
		return medicineDao.loadMedicine(medicine);
	}

	public Medicine getMedicineById(Long id) {
		logger.info("Start getMedicineById");
		logger.debug("Id: " + id);
		logger.info("End getMedicineById");
		return medicineDao.loadMedicineById(id);
	}

	public List<Medicine> listMedicine(Medicine searchTemplate) {
		return medicineDao.listMedicine(searchTemplate);
	}
	
	public List<Medicine> listMedicine(String searchField, String searchString, String searchOper, String sidx, String sord, Integer page, Integer rows) {
		return medicineDao.listMedicine(searchField, searchString, searchOper, sidx, sord, page, rows);
	}
	
	public Integer countListMedicine(String searchField, String searchString, String searchOper) {
		return medicineDao.countListMedicine(searchField, searchString, searchOper);
	}
	
	public Medicine saveOrUpdateMedicine(Medicine medicine) {
		return medicineDao.saveOrUpdateMedicine(medicine);
	}
	
	public void deleteMedicine(Medicine medicine) {
		logger.info("Start deleteMedicine");
		medicineDao.deleteMedicine(medicine);
		logger.info("End deleteMedicine");
	}

	/**
	 * @param medicineDao the medicineDao to set
	 */
	public void setMedicineDao(MedicineDao medicineDao) {
		logger.info("Start setMedicineDao");
		logger.debug("Medicine Dao: " + medicineDao);
		this.medicineDao = medicineDao;
		logger.info("End setMedicineDao");
	}

}
